package com.cjh.lms.controller;

import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.forwardedUrl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.cjh.lms.pojo.TOpenLog;
import com.cjh.lms.pojo.TRepairLog;

import com.cjh.lms.service.BackInfoService;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;

@Controller
public class BackInfoController {
	
	@Autowired
	BackInfoService backInfoService;
	
	//开锁记录回传
	@RequestMapping("unLockInfo")
	@ResponseBody
	public void unLockInfo(String data){
		Gson gson = new GsonBuilder().setDateFormat("yyyy-MM-dd HH:mm:ss").create();
		List<TOpenLog> tOpenLog = gson.fromJson(data, new TypeToken<List<TOpenLog>>(){}.getType());
		backInfoService.unLockInfo(tOpenLog);
	}
	
	//维修记录回传
	@RequestMapping("repairLogInfo")
	@ResponseBody
	public void repairLogInfo(String data){
		Gson gson = new GsonBuilder()
				.setDateFormat("yyyy-MM-dd HH:mm:ss")
				.create();
		List<TRepairLog> tRepairLog = gson.fromJson(data, new TypeToken<List<TRepairLog>>(){}.getType());
		backInfoService.repairLogInfo(tRepairLog);
	}
	
}
